<template>
  <div class="app-container">
    <!--<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="类型" prop="taskType">
        <el-select v-model="queryParams.taskType" placeholder="请选择类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="指派单位" prop="taskDeptCode">
        <el-input
          v-model="queryParams.taskDeptCode"
          placeholder="请输入指派单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="指派时间" prop="assignTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.assignTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择指派时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="截止登记日期" prop="planCompleteTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.planCompleteTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择截止登记日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="状态" prop="taskState">
        <el-input
          v-model="queryParams.taskState"
          placeholder="请输入状态"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="协同检查人" prop="coinspector">
        <el-input
          v-model="queryParams.coinspector"
          placeholder="请输入协同检查人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检查类型" prop="taskCheckType">
        <el-select v-model="queryParams.taskCheckType" placeholder="请选择检查类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否协同" prop="synergistic">
        <el-input
          v-model="queryParams.synergistic"
          placeholder="请输入是否协同"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检查结果" prop="taskResultType">
        <el-select v-model="queryParams.taskResultType" placeholder="请选择检查结果" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="检查时间" prop="checkTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.checkTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择检查时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="检查人" prop="examiner">
        <el-input
          v-model="queryParams.examiner"
          placeholder="请输入检查人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>-->

    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="县区" prop="city" v-show="cityShow">
        <el-select
          v-model="queryParams.city"
          clearable
          placeholder="请选择"
          size="small"
          @change="selectCity"
        >
          <el-option
            v-for="item in this.cityData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="乡镇" prop="town" v-show="townShow">
        <el-select
          v-model="queryParams.town"
          clearable
          placeholder="请选择"
          size="small"
          @change="selectTown"
        >
          <el-option
            v-for="item in this.townData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="村" prop="village" v-show="villageShow">
        <el-select
          v-model="queryParams.village"
          clearable
          placeholder="请选择"
          size="small"
          @change="selectVillage"
        >
          <el-option
            v-for="item in this.villageData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="任务状态" prop="taskState">
        <el-select
          v-model="taskState"
          placeholder="请选择"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in superviseTaskState"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="检查结果" prop="taskResultType">
        <el-select
          v-model="queryParams.taskResultType"
          placeholder="请选择"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in superviseCheckResult"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['supervise:supervise:add']"
          >新增
        </el-button>
      </el-col>
      <!--<el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['supervise:supervise:edit']"
        >修改
        </el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['supervise:supervise:remove']"
          >删除
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">
              <el-button
                type="warning"
                icon="el-icon-download"
                size="mini"
                @click="handleExport"
                v-hasPermi="['supervise:supervise:export']"
              >导出</el-button>
            </el-col>-->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div class="show-icon">
      注释：若检查时间晚于任务截止时间，则行政区划以
      <span style="color: red">红色</span> 展示
    </div>
    <div class="show-signal"></div>
    <el-table
      v-loading="loading"
      :data="superviseList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
        align="center"
        :selectable="checkboxList"
      />
      <el-table-column label="任务编号" align="center" prop="taskNo" />
      <el-table-column
        label="任务执行单位"
        align="center"
        prop="taskDeptName"
      />
      <el-table-column
        label="行政区划"
        min-width="120"
        align="center"
        prop="taskDeptCode"
      >
        <template slot-scope="scope">
          <span
            v-if="
              scope.row.planCompleteTime < scope.row.checkTime ||
              (scope.row.planCompleteTime < new Date() &&
                (scope.row.checkTime == '' || scope.row.checkTime == null))
            "
            style="color: red"
            >{{ scope.row.countyName }}-{{ scope.row.townshipName }}-{{
              scope.row.superviseDeptName
            }}</span
          >
          <span v-else
            >{{ scope.row.countyName }}-{{ scope.row.townshipName }}-{{
              scope.row.superviseDeptName
            }}</span
          >
        </template>
      </el-table-column>
      <!--  -->
      <el-table-column label="承包方名称" align="center" prop="cbfmc" />
      <el-table-column label="地块编码" align="center" prop="dkbm" />
      <el-table-column label="退耕年份" align="center" prop="tyear" />
      <el-table-column label="面积（亩）" align="center" prop="scmjm" />
      <el-table-column label="土地性质" align="center" prop="dksx" />
      <el-table-column label="附着物" align="center" prop="fzwlx" />
      <!--  -->
      <el-table-column
        label="任务派发时间"
        align="center"
        prop="assignTime"
        width="180"
      >
        <template slot-scope="scope">
          <!--          <span>{{ parseTime(scope.row.assignTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>-->
          <span>{{ parseTime(scope.row.assignTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="任务截止时间"
        align="center"
        prop="assignTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.planCompleteTime, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="任务状态"
        align="center"
        prop="taskState"
        :formatter="taskStateFormat"
      />
      <el-table-column
        label="检查时间"
        align="center"
        prop="checkTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.checkTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="检查结果"
        align="center"
        prop="taskResultType"
        :formatter="taskResultTypeFormat"
      />
      <!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['supervise:supervise:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['supervise:supervise:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <!--<el-table v-loading="loading" :data="superviseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="taskNo" />
      <el-table-column label="类型" align="center" prop="taskType" />
      <el-table-column label="指派单位" align="center" prop="taskDeptCode" />
      <el-table-column label="指派时间" align="center" prop="assignTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.assignTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="截止登记日期" align="center" prop="planCompleteTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planCompleteTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="taskState" />
      <el-table-column label="协同检查人" align="center" prop="coinspector" />
      <el-table-column label="检查类型" align="center" prop="taskCheckType" />
      <el-table-column label="是否协同" align="center" prop="synergistic" />
      <el-table-column label="检查结果" align="center" prop="taskResultType" />
      <el-table-column label="检查时间" align="center" prop="checkTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.checkTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检查人" align="center" prop="examiner" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['supervise:supervise:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['supervise:supervise:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>-->

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
      @close="cancel"
    >
      <el-steps
        :active="active"
        finish-status="success"
        align-center
        style="margin-bottom: 20px"
      >
        <el-step title="填写信息"></el-step>
        <el-step title="任务派发"></el-step>
      </el-steps>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="140px"
        v-if="active == 0"
      >
        <el-form-item label="任务类型" prop="taskType">
          <el-select
            v-model="form.taskType"
            placeholder="请选择"
            style="width: 100%"
            @change="selectTaskType"
            :disabled="iscountry"
          >
            <el-option
              v-for="dict in superviseTaskType"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="任务接收单位" prop="taskDeptCode">
          <!--          <el-input v-model="form.taskDeptCode" placeholder="请输入指派的任务单位"/>-->
          <el-select
            v-if="this.deptCodeStep == 2"
            :disabled="iscountry"
            v-model="form.taskDeptCode"
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in this.townFormData"
              :key="item.deptCode"
              :label="item.deptName"
              :value="item.deptCode"
            >
            </el-option>
          </el-select>
          <!--<el-select disabled v-else-if="this.deptCodeStep==3" v-model="form.taskDeptCode" placeholder="请选择"
                     style="width: 100%"
          >3
            <el-option
              v-for="item in this.villageFormData"
              :key="item.deptCode"
              :label="item.deptName"
              :value="item.deptCode">
            </el-option>
          </el-select>-->
          <el-select
            :disabled="isShow ? true : false"
            v-else
            v-model="form.taskDeptCode"
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in this.cityFormData"
              :key="item.deptCode"
              :label="item.deptName"
              :value="item.deptCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="协同检查"
          prop="synergistic"
          v-show="isShow && !iscountry"
        >
          <el-select
            v-model="form.synergistic"
            placeholder="请选择"
            style="width: 20%"
            @change="handleSynergistic"
          >
            <el-option
              v-for="dict in synergisticData"
              :key="dict.value"
              :label="dict.name"
              :value="dict.value"
            />
          </el-select>
          <el-select
            v-model="form.coinspector"
            placeholder="请选择"
            style="width: 80%"
            :disabled="
              form.synergistic == 'N' ||
              form.synergistic == null ||
              form.synergistic == ''
                ? true
                : false
            "
            multiple
          >
            <el-option
              v-for="item in zzFormData"
              :key="item.deptCode"
              :label="item.deptName"
              :value="item.deptCode"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="协同时间"
          prop="coinspectTime"
          v-show="isShow && !iscountry"
        >
          <el-date-picker
            clearable
            size="small"
            style="width: 100%"
            :disabled="
              form.synergistic == 'N' ||
              form.synergistic == null ||
              form.synergistic == ''
                ? true
                : false
            "
            v-model="form.coinspectTime"
            type="date"
            :picker-options="startDatePicker"
            value-format="yyyy-MM-dd"
            placeholder="选择任务协同时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="随机任务" prop="randomable">
          <el-select
            v-model="form.randomable"
            placeholder="请选择"
            style="width: 20%"
            @change="handleRandomable"
          >
            <el-option
              v-for="dict in randomableData"
              :key="dict.value"
              :label="dict.name"
              :value="dict.value"
            />
          </el-select>
          <el-input
            v-model="form.randomPercent"
            :disabled="form.randomable != true"
            placeholder="请输入比例"
            type="number"
            min="1"
            max="100"
            style="width: 80%"
            @input="handleRatio"
          />
        </el-form-item>
        <el-form-item label="任务派发时间" prop="assignTime">
          <el-date-picker
            v-model="form.assignTime"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="任务截止登记日期" prop="planCompleteTime">
          <el-date-picker
            clearable
            size="small"
            style="width: 100%"
            v-model="form.planCompleteTime"
            type="date"
            :picker-options="startDatePicker"
            value-format="yyyy-MM-dd"
            placeholder="选择任务截止登记日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="检查方式" prop="taskCheckType">
          <el-select
            v-model="form.taskCheckType"
            placeholder="请选择"
            style="width: 100%"
            multiple
          >
            <el-option
              v-for="dict in superviseCheckType"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <div style="min-height: 500px" v-if="active == 1">
        <el-form
          :model="queryAddParams"
          ref="queryForm"
          :inline="true"
          v-show="randomable"
        >
          <el-form-item label="县区" prop="city" v-show="cityFormShow">
            <el-select
              v-model="queryAddParams.city"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddCity"
            >
              <el-option
                v-for="item in this.cityQueryData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="乡镇" prop="town" v-show="townFormShow">
            <el-select
              v-model="queryAddParams.town"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddTown"
            >
              <el-option
                v-for="item in this.townQueryData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="村" prop="village" v-show="villageFormShow">
            <el-select
              v-model="queryAddParams.village"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddVillage"
            >
              <el-option
                v-for="item in this.villageQueryData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="任务状态" prop="taskState">
            <el-select
              v-model="taskStates"
              placeholder="请选择"
              clearable
              size="small"
            >
              <el-option
                v-for="dict in superviseTaskState"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="检查结果" prop="taskResultType">
            <el-select
              v-model="queryAddParams.taskResultType"
              placeholder="请选择"
              clearable
              size="small"
            >
              <el-option
                v-for="dict in superviseCheckResult"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              type="cyan"
              icon="el-icon-search"
              size="mini"
              @click="handleAddQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetAddQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <!-- <el-row :gutter="10" class="mb8">
           <el-col :span="1.5">
             <el-button
               type="primary"
               icon="el-icon-plus"
               size="mini"
               :disabled="multipleAdd"
               @click="handleSendTask"
             >任务派发
             </el-button>
           </el-col>
           &lt;!&ndash;          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>&ndash;&gt;
         </el-row>-->
        <el-table
          v-loading="loading"
          ref="multipleTable"
          :data="superviseAddList"
          @selection-change="handleAddSelectionChange"
        >
          <el-table-column
            type="selection"
            width="55"
            align="center"
            :selectable="checkboxT"
          />
          <el-table-column
            label="行政区划"
            align="center"
            prop="superviseDeptCode"
          >
            <template slot-scope="scope">
              {{ scope.row.countyName }}-{{ scope.row.townshipName }}-{{
                scope.row.superviseDeptName
              }}
            </template>
          </el-table-column>
          <el-table-column label="承包方名称" align="center" prop="cbfmc" />
          <el-table-column label="地块编码" align="center" prop="dkbm" />
          <el-table-column label="退耕年份" align="center" prop="tyear" />
          <el-table-column label="面积（亩）" align="center" prop="scmjm" />
          <el-table-column label="土地性质" align="center" prop="dksx" />
          <el-table-column label="附着物" align="center" prop="fzwlx" />
          <el-table-column
            label="最近任务派发时间"
            align="center"
            prop="assignTime"
            width="180"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.assignTime == '' ||
                  scope.row.assignTime == null ||
                  scope.row.assignTime == undefined
                "
                >-</span
              >
              <span v-else>{{
                parseTime(scope.row.assignTime, "{y}-{m}-{d} {h} {i} {s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="任务状态"
            align="center"
            prop="taskState"
            :formatter="taskStateFormat"
          >
          </el-table-column>
          <el-table-column
            label="最近检查时间"
            align="center"
            prop="checkTime"
            width="180"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.checkTime == '' ||
                  scope.row.checkTime == null ||
                  scope.row.checkTime == undefined
                "
                >-</span
              >
              <span v-else>{{
                parseTime(scope.row.checkTime, "{y}-{m}-{d} {h} {i} {s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="检查结果"
            align="center"
            prop="taskResultType"
            :formatter="taskResultTypeFormat"
          >
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" plain @click="pres" v-if="active == 1"
          >上一步</el-button
        >
        <el-button type="success" plain @click="next" v-if="active == 0"
          >下一步</el-button
        >
        <el-button
          type="success"
          plain
          @click="submitForm('0')"
          v-if="active == 1"
          >完成</el-button
        >
        <el-button
          type="success"
          plain
          @click="submitForm('1')"
          v-if="active == 1"
          >完成并授权</el-button
        >
      </div>
    </el-dialog>

    <!--    添加监督任务-->
    <el-dialog
      :title="title"
      :visible.sync="openList"
      width="1300px"
      append-to-body
    >
      <div style="min-height: 500px">
        <el-form
          :model="queryAddParams"
          ref="queryForm"
          :inline="true"
          v-show="showSearch"
        >
          <el-form-item label="县区" prop="city" v-show="cityShow">
            <el-select
              v-model="queryAddParams.city"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddCity"
            >
              <el-option
                v-for="item in this.cityData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="乡镇" prop="town" v-show="townShow">
            <el-select
              v-model="queryAddParams.town"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddTown"
            >
              <el-option
                v-for="item in this.townData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="村" prop="village" v-show="villageShow">
            <el-select
              v-model="queryAddParams.village"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectAddVillage"
            >
              <el-option
                v-for="item in this.villageData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="任务状态" prop="taskState">
            <el-select
              v-model="taskStates"
              multiple
              placeholder="请选择"
              clearable
              size="small"
            >
              <el-option
                v-for="dict in superviseTaskState"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="检查结果" prop="taskResultType">
            <el-select
              v-model="queryAddParams.taskResultType"
              placeholder="请选择"
              clearable
              size="small"
            >
              <el-option
                v-for="dict in superviseCheckResult"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              type="cyan"
              icon="el-icon-search"
              size="mini"
              @click="handleAddQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetAddQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              :disabled="multipleAdd"
              @click="handleSendTask"
              >任务派发
            </el-button>
          </el-col>
          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row>
        <el-table
          v-loading="loading"
          :data="superviseAddList"
          @selection-change="handleAddSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column
            label="行政区划"
            align="center"
            prop="superviseDeptCode"
          >
            <template slot-scope="scope">
              {{ scope.row.countyName }}-{{ scope.row.townshipName }}-{{
                scope.row.superviseDeptName
              }}
            </template>
          </el-table-column>
          <el-table-column
            label="最近任务派发时间"
            align="center"
            prop="assignTime"
            width="180"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.assignTime == '' ||
                  scope.row.assignTime == null ||
                  scope.row.assignTime == undefined
                "
                >-</span
              >
              <span v-else>{{
                parseTime(scope.row.assignTime, "{y}-{m}-{d} {h} {i} {s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="任务状态"
            align="center"
            prop="taskState"
            :formatter="taskStateFormat"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.taskState == '' ||
                  scope.row.taskState == null ||
                  scope.row.taskState == undefined
                "
                >-</span
              >
            </template>
          </el-table-column>
          <el-table-column
            label="最近检查时间"
            align="center"
            prop="checkTime"
            width="180"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.checkTime == '' ||
                  scope.row.checkTime == null ||
                  scope.row.checkTime == undefined
                "
                >-</span
              >
              <span v-else>{{
                parseTime(scope.row.checkTime, "{y}-{m}-{d} {h} {i} {s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="检查结果"
            align="center"
            prop="taskResultType"
            :formatter="taskResultTypeFormat"
          >
            <template slot-scope="scope">
              <span
                v-if="
                  scope.row.taskResultType == '' ||
                  scope.row.taskResultType == null ||
                  scope.row.taskResultType == undefined
                "
                >-</span
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        v-show="totalAdd > 0"
        :total="totalAdd"
        :page.sync="queryAddParams.pageNum"
        :limit.sync="queryAddParams.pageSize"
        @pagination="getAddList"
      />
    </el-dialog>

    <!--<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  <el-form ref="form" :model="form" :rules="rules" label-width="80px">
    <el-form-item label="任务类型 0本级 1下级" prop="taskType">
      <el-select v-model="form.taskType" placeholder="请选择任务类型 0本级 1下级">
        <el-option label="请选择字典生成" value="" />
      </el-select>
    </el-form-item>
    <el-form-item label="指派的任务单位" prop="taskDeptCode">
      <el-input v-model="form.taskDeptCode" placeholder="请输入指派的任务单位" />
    </el-form-item>
    <el-form-item label="任务指派时间" prop="assignTime">
      <el-date-picker clearable size="small" style="width: 200px"
        v-model="form.assignTime"
        type="date"
        value-format="yyyy-MM-dd"
        placeholder="选择任务指派时间">
      </el-date-picker>
    </el-form-item>
      <el-form-item label="任务截止登记日期" prop="planCompleteTime">
      <el-date-picker clearable size="small" style="width: 200px"
        v-model="form.planCompleteTime"
        type="date"
        value-format="yyyy-MM-dd"
        placeholder="选择任务截止登记日期">
      </el-date-picker>
    </el-form-item>
    <el-form-item label="任务状态 0待派发 1待执行 2已执行" prop="taskState">
      <el-input v-model="form.taskState" placeholder="请输入任务状态 0待派发 1待执行 2已执行" />
    </el-form-item>
    <el-form-item label="经度" prop="longitude">
      <el-input v-model="form.longitude" placeholder="请输入经度" />
    </el-form-item>
    <el-form-item label="协同检查人" prop="coinspector">
      <el-input v-model="form.coinspector" placeholder="请输入协同检查人" />
    </el-form-item>
    <el-form-item label="维度" prop="dimension">
      <el-input v-model="form.dimension" placeholder="请输入维度" />
    </el-form-item>
    <el-form-item label="任务检查类型 0实地 1其他" prop="taskCheckType">
      <el-select v-model="form.taskCheckType" placeholder="请选择任务检查类型 0实地 1其他">
        <el-option label="请选择字典生成" value="" />
      </el-select>
    </el-form-item>
    <el-form-item label="是否协同 Y是 N否" prop="synergistic">
      <el-input v-model="form.synergistic" placeholder="请输入是否协同 Y是 N否" />
    </el-form-item>
    <el-form-item label="检查结果 0代表合格 1代表不合格" prop="taskResultType">
      <el-select v-model="form.taskResultType" placeholder="请选择检查结果 0代表合格 1代表不合格">
        <el-option label="请选择字典生成" value="" />
      </el-select>
    </el-form-item>
    <el-form-item label="附件" prop="reportfj">
      <el-input v-model="form.reportfj" placeholder="请输入附件" />
    </el-form-item>
    <el-form-item label="检查时间" prop="checkTime">
      <el-date-picker clearable size="small" style="width: 200px"
        v-model="form.checkTime"
        type="date"
        value-format="yyyy-MM-dd"
        placeholder="选择检查时间">
      </el-date-picker>
    </el-form-item>
    <el-form-item label="备用1" prop="by1">
      <el-input v-model="form.by1" placeholder="请输入备用1" />
    </el-form-item>
    <el-form-item label="检查人" prop="examiner">
      <el-input v-model="form.examiner" placeholder="请输入检查人" />
    </el-form-item>
    <el-form-item label="备用2" prop="by2">
      <el-input v-model="form.by2" placeholder="请输入备用2" />
    </el-form-item>
    <el-form-item label="备用3" prop="by3">
      <el-input v-model="form.by3" placeholder="请输入备用3" />
    </el-form-item>
    <el-form-item label="备用4" prop="by4">
      <el-input v-model="form.by4" placeholder="请输入备用4" />
    </el-form-item>
    <el-form-item label="备用5" prop="by5">
      <el-input v-model="form.by5" placeholder="请输入备用5" />
    </el-form-item>
    <el-form-item label="删除标志" prop="delFlag">
      <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitForm">确 定</el-button>
    <el-button @click="cancel">取 消</el-button>
  </div>
</el-dialog>-->
  </div>
</template>

<script>
import {
  delSupervise,
  distributeSupervise,
  exportSupervise,
  getSupervise,
  listForAdd,
  listSupervise,
} from "@/api/jdgl/supervise";
import { getInfo } from "@/api/login";
import { childlistUse } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "Supervise",
  components: { Treeselect },
  data() {
    return {
      startDatePicker: this.beginDate(),
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      idsAdd: [],
      idsAdds: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      singleAdd: true,
      // 非多个禁用
      multipleAdd: true,
      // 显示搜索条件
      showSearch: true,
      // 菜单树选项
      deptOptions: [],
      // 总条数
      total: 0,
      totalAdd: 0,
      isShow: false,
      iscountry: false,
      myDeptCode: "",
      deptCode: "",
      deptCodeStep: 0,
      // 监督管理表格数据
      superviseList: [],
      superviseAddList: [],
      superviseTaskType: [],
      superviseCheckResult: [],
      superviseTaskState: [],
      superviseCheckType: [],
      city: "",
      town: "",
      village: "",
      cityShow: "",
      townShow: "",
      villageShow: "",
      cityFormShow: false,
      townFormShow: false,
      villageFormShow: false,
      cityData: [],
      townData: [],
      villageData: [],
      cityAddData: [],
      townAddData: [],
      villageAddData: [],
      cityFormData: [],
      townFormData: [],
      villageFormData: [],
      cityQueryData: [],
      townQueryData: [],
      villageQueryData: [],
      zzFormData: [],
      randomableData: [
        { name: "是", value: true },
        { name: "否", value: false },
      ],
      synergisticData: [
        { name: "是", value: "Y" },
        { name: "否", value: "N" },
      ],
      // 弹出层标题
      title: "",
      active: 0,
      // 是否显示弹出层
      open: false,
      openList: false,
      randomable: false,
      taskState: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        taskNo: null,
        taskType: null,
        taskDeptCode: null,
        assignTime: null,
        planCompleteTime: null,
        taskState1: null,
        taskState: null,
        taskStates: null,
        longitude: null,
        coinspector: null,
        dimension: null,
        taskCheckType: null,
        synergistic: null,
        taskResultType: null,
        reportfj: null,
        checkTime: null,
        by1: null,
        examiner: null,
        by2: null,
        by3: null,
        by4: null,
        by5: null,
      },
      taskStates: "",
      queryAddParams: {
        pageNum: 1,
        pageSize: 100,
        superviseDeptCode: null,
        taskResultType: null,
        taskStates: null,
        city: null,
        town: null,
        village: null,
      },
      // 表单参数
      form: {
        assignTime: "",
        superviseId: null,
        coinspectTime: null,
        taskNo: null,
        randomable: null,
        randomPercent: null,
        taskType: null,
        taskDeptCode: null,
        assignTime: null,
        planCompleteTime: null,
        taskState: null,
        longitude: null,
        coinspector: null,
        dimension: null,
        taskCheckType: null,
        synergistic: null,
        taskResultType: null,
        reportfj: null,
        checkTime: null,
        by1: null,
        examiner: null,
        by2: null,
        by3: null,
        by4: null,
        by5: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      },
      // 表单校验
      rules: {
        taskType: [
          { required: true, message: "任务类型不能为空", trigger: "change" },
        ],
        randomable: [
          { required: true, message: "随机生成不能为空", trigger: "change" },
        ],
        taskDeptCode: [
          { required: true, message: "任务接收单位不能为空", trigger: "blur" },
        ],
        /*synergistic: [
          {required: true, message: "协同检查不能为空", trigger: "change"}
        ],*/
        taskCheckType: [
          { required: true, message: "检查方式不能为空", trigger: "change" },
        ],
        assignTime: [
          { required: true, message: "检查方式不能为空", trigger: "blur" },
        ],
        planCompleteTime: [
          {
            required: true,
            message: "任务截止登记时间不能为空",
            trigger: "change",
          },
        ],
      },
    };
  },
  created() {
    this.getDicts("supervise_task_type").then((response) => {
      this.superviseTaskType = response.data;
    });
    this.getDicts("supervise_check_type").then((response) => {
      this.superviseCheckType = response.data;
    });
    this.getDicts("supervise_check_result").then((response) => {
      this.superviseCheckResult = response.data;
    });
    this.getDicts("supervise_task_state").then((response) => {
      this.superviseTaskState = response.data;
    });

    getInfo().then((response) => {
      let deptCode = response.user.dept.deptCode;
      this.myDeptCode = deptCode;
      this.getList();
      if (deptCode.length == 4) {
        //新区
        this.cityShow = true;
        this.townShow = true;
        this.villageShow = true;
        childlistUse(deptCode).then((response) => {
          this.cityData = response.data;
        });
      } else if (deptCode.length == 6) {
        //县
        this.cityShow = false;
        this.townShow = true;
        this.villageShow = true;
        childlistUse(deptCode).then((response) => {
          this.townData = response.data;
        });
      } else if (deptCode.length == 9) {
        //镇
        this.iscountry = true;
        this.cityShow = false;
        this.townShow = false;
        this.villageShow = true;
        childlistUse(deptCode).then((response) => {
          this.villageData = response.data;
        });
      } else if (deptCode.length == 12) {
        //村
        this.cityShow = false;
        this.townShow = false;
        this.villageShow = false;
      } else {
        this.childlist(1306);
        this.cityShow = true;
        this.townShow = true;
        this.villageShow = true;
      }
    });
  },
  methods: {
    selectDepart(val) {
      this.form.coinspector = val.deptCode;
      /*let _this=this;
      if (val.deptCode.length >= 12) {
        _this.form.coinspector = null;
        _this.$message.warning("不允许选择村");
        return false;
      }*/
    },
    beginDate() {
      let self = this;
      let timestamp = new Date().getTime();
      return {
        disabledDate(time) {
          if (self.form.coinspectTime) {
            return (
              new Date(self.form.coinspectTime).getTime() > time.getTime() &&
              timestamp > time.getTime()
            );

            /*let date = parseInt(self.tyear) + '-12-31 00:00:00';
            date = date.substring(0, 19);
            date = date.replace(/-/g, '/');
            let timestamp = new Date(date).getTime();
            if (self.form.cbqxz) {  //如果结束时间不为空，则小于结束时间
              return new Date(self.form.cbqxz).getTime() < time.getTime() || timestamp < time.getTime();
            } else {
              return timestamp < time.getTime();
            }*/
          } else {
            return timestamp > time.getTime();
          }
        },
      };
    },
    checkboxList(row, rowIndex) {
      if (row.taskState != "2") {
        return true; //禁用
      } else {
        return false; //不禁用
      }
    },
    checkboxT(row, rowIndex) {
      if (this.randomable) {
        return true; //禁用
      } else {
        return false; //不禁用
      }
    },
    handleRatio(val) {
      if (val != null && val != "" && val != undefined) {
        if (val > 0 && val <= 100) {
        } else {
          this.$message.warning("比例只允许在0-100之间");
          this.form.randomPercent = "";
        }
      } else {
        this.form.randomPercent = "";
      }
    },
    handleSynergistic(val) {
      if (val == "N") {
        this.form.coinspector = null;
        this.form.coinspectTime = null;
      }
    },
    handleRandomable(val) {
      this.randomable = !val;
      if (!val) {
        this.form.randomPercent = "";
      } else {
        this.form.randomPercent = "";
        this.queryAddParams.superviseDeptCode = "";
        this.queryAddParams.taskStates = "";
        // this.queryAddParams.taskStates = '0,1';
      }
    },
    /** 转换菜单数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children,
      };
    },

    selectTaskType(val) {
      this.form.taskDeptCode = "";
      if (val == "0") {
        this.deptOptions = [];
        this.isShow = true;
        this.form.synergistic = "";
        this.form.coinspector = null;
        getInfo().then((response) => {
          let deptCode = response.user.dept.deptCode;
          this.myDeptCode = deptCode;
          childlistUse(deptCode).then((response) => {
            this.zzFormData = response.data;
          });
          if (deptCode.length == 4) {
            //新区
            this.deptCodeStep = 0;
            let newdeptCode = deptCode.substring(0, 2);
            childlistUse(newdeptCode).then((response) => {
              this.cityFormData = response.data;
              this.form.taskDeptCode = deptCode;
            });
          } else if (deptCode.length == 6) {
            //县
            this.deptCodeStep = 1;
            let newdeptCode = deptCode.substring(0, 4);
            childlistUse(newdeptCode).then((response) => {
              this.cityFormData = response.data;
              this.form.taskDeptCode = deptCode;
            });
          } else if (deptCode.length == 9) {
            //镇
            this.deptCodeStep = 2;
            let newdeptCode = deptCode.substring(0, 6);
            childlistUse(newdeptCode).then((response) => {
              this.villageFormData = response.data;
            });
          } else if (deptCode.length == 12) {
            //村
          }
        });
      } else {
        this.isShow = false;
        this.form.synergistic = "";
        this.form.coinspector = null;
        this.form.coinspectTime = null;
        getInfo().then((response) => {
          let deptCode = response.user.dept.deptCode;
          this.deptCode = deptCode;
          if (deptCode.length == 4) {
            //新区
            this.deptCodeStep = 0;
            childlistUse(deptCode).then((response) => {
              this.cityFormData = response.data;
            });
          } else if (deptCode.length == 6) {
            //县
            this.deptCodeStep = 1;
            childlistUse(deptCode).then((response) => {
              this.cityFormData = response.data;
            });
            /* deptCode = deptCode.substring(0, 4);
             childlistUse(deptCode).then(response => {
               this.cityFormData = response.data;
             });*/
          } else if (deptCode.length == 9) {
            //镇
            this.deptCodeStep = 3;
            childlistUse(deptCode).then((response) => {
              this.villageFormData = response.data;
            });
          } else if (deptCode.length == 12) {
            //村
          }
        });
      }
    },

    /*selectTaskType(val) {
      this.form.taskDeptCode = "";
      if (val == "0") {
        this.isShow = true;
        this.form.synergistic = "";
        this.form.coinspector = null;
        getInfo().then(response => {
          let deptCode = response.user.dept.deptCode;

          this.deptCode = deptCode;
          listDept({deptCode: deptCode}).then(response => {
            let dataNew = [];
            let len = response.data.length;
            let i = 0;
            response.data.forEach(item => {
              i++;
              if (item.deptCode.length < 12) {
                dataNew.push(item);
                if (len == i) {
                  const dept = {deptId: 0, deptName: '请选择协查单位', children: []};
                  let deptCodeNew = [];

                  dept.children = this.handleTree(dataNew, "deptId");
                  this.deptOptions.push(dept);
                }
              } else {
                if (len == i) {
                  const dept = {deptId: 0, deptName: '请选择协查单位', children: []};
                  let deptCodeNew = [];

                  dept.children = this.handleTree(dataNew, "deptId");
                  this.deptOptions.push(dept);
                }
              }
            })
          });

          if (deptCode.length == 4) {//新区
            this.deptCodeStep = 0;
            let newdeptCode = deptCode.substring(0, 2);
            childlistUse(newdeptCode).then(response => {
              this.cityFormData = response.data;
              this.form.taskDeptCode = deptCode;
            });
          } else if (deptCode.length == 6) {//县
            this.deptCodeStep = 1;
            let newdeptCode = deptCode.substring(0, 4);
            childlistUse(newdeptCode).then(response => {
              this.cityFormData = response.data;
              this.form.taskDeptCode = deptCode;
            });
          } else if (deptCode.length == 9) {//镇
            this.deptCodeStep = 2
            let newdeptCode = deptCode.substring(0, 6);
            childlistUse(newdeptCode).then(response => {
              this.villageFormData = response.data;
            });
          } else if (deptCode.length == 12) {//村
          }
        });
      } else {
        this.isShow = false;
        this.form.synergistic = "";
        this.form.coinspector = null;
        getInfo().then(response => {
          let deptCode = response.user.dept.deptCode;
          this.deptCode = deptCode;
          if (deptCode.length == 4) {//新区
            this.deptCodeStep = 0;
            childlistUse(deptCode).then(response => {
              this.cityFormData = response.data;
            });
          } else if (deptCode.length == 6) {//县
            this.deptCodeStep = 1;
            childlistUse(deptCode).then(response => {
              this.cityFormData = response.data;
            });
            /!* deptCode = deptCode.substring(0, 4);
             childlistUse(deptCode).then(response => {
               this.cityFormData = response.data;
             });*!/
          } else if (deptCode.length == 9) {//镇
            this.deptCodeStep = 3;
            childlistUse(deptCode).then(response => {
              this.villageFormData = response.data;
            });
          } else if (deptCode.length == 12) {//村
          }
        });
      }
    },*/
    // 选择县
    selectCity(val) {
      this.city = val;
      this.queryParams.cbfbm = val;
      this.queryParams.superviseDeptCode = val;
      if (val != "" && val != null) {
        childlistUse(val).then((response) => {
          this.townData = response.data;
        });
      }
    },
    // 选择镇
    selectTown(val) {
      this.town = val;
      this.queryParams.cbfbm = val;
      this.queryParams.superviseDeptCode = val;
      if (val != "" && val != null) {
        childlistUse(val).then((response) => {
          this.villageData = response.data;
        });
      }
    },
    // 选择村
    selectVillage(val) {
      this.queryParams.cbfbm = val;
      this.queryParams.superviseDeptCode = val;
      this.village = val;
    },
    // 选择县
    selectAddCity(val) {
      this.city = val;
      this.queryAddParams.superviseDeptCode = val;
      this.queryAddParams.town = "";
      if (val != "" && val != null) {
        childlistUse(val).then((response) => {
          // this.townAddData = response.data;
          this.townQueryData = response.data;
        });
      }
    },
    // 选择镇
    selectAddTown(val) {
      this.town = val;
      this.queryAddParams.superviseDeptCode = val;
      this.queryAddParams.village = "";
      if (val != "" && val != null) {
        childlistUse(val).then((response) => {
          // this.villageAddData = response.data;
          this.villageQueryData = response.data;
        });
      }
    },
    // 选择村
    selectAddVillage(val) {
      this.queryAddParams.superviseDeptCode = val;
    },
    // 字典状态字典翻译
    taskStateFormat(row, column) {
      return this.selectDictLabel(this.superviseTaskState, row.taskState);
    },
    taskResultTypeFormat(row, column) {
      return this.selectDictLabel(
        this.superviseCheckResult,
        row.taskResultType
      );
    },
    /** 查询监督管理列表 */
    getList() {
      this.loading = true;
      let _this = this;
      if (this.taskState == "" || this.taskState == null) {
        this.queryParams.taskStates = "0,1";
      }
      let taskStates = this.taskState;
      this.queryParams.taskStates = taskStates.toString();
      // this.queryParams.taskDeptCode = this.deptCode;
      this.queryParams.distByDeptCode = this.myDeptCode;
      // this.queryParams.superviseDeptCode = this.deptCode;
      // this.queryParams.taskStates = this.queryParams.taskState.toString();
      listSupervise(this.queryParams).then((response) => {
        this.superviseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getAddList() {
      this.loading = true;
      if (
        this.queryAddParams.superviseDeptCode == "" ||
        this.queryAddParams.superviseDeptCode == null
      ) {
        this.queryAddParams.superviseDeptCode = this.form.taskDeptCode;
      }
      this.queryAddParams.randomable = this.form.randomable;
      this.queryAddParams.randomPercent = this.form.randomPercent;

      if (this.taskStates == "" || this.taskStates == null) {
        this.queryAddParams.taskStates = "";
        listForAdd(this.queryAddParams).then((response) => {
          this.superviseAddList = response.rows;
          this.totalAdd = response.total;
          this.loading = false;
        });
      } else {
        this.queryAddParams.taskStates = this.taskStates.toString();
        listForAdd(this.queryAddParams).then((response) => {
          this.superviseAddList = response.rows;
          this.totalAdd = response.total;
          this.loading = false;
        });
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.active = 0;
      this.queryAddParams.taskResultType = "";
      this.isShow = false;
      this.form.synergistic = "";
      this.form.coinspector = null;
      this.form.coinspectTime = null;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        superviseId: null,
        taskNo: null,
        randomable: null,
        coinspector1: null,
        randomPercent: null,
        taskType: null,
        taskDeptCode: null,
        assignTime: null,
        planCompleteTime: null,
        taskState: null,
        longitude: null,
        coinspector: null,
        dimension: null,
        taskCheckType: null,
        synergistic: null,
        taskResultType: null,
        reportfj: null,
        checkTime: null,
        by1: null,
        examiner: null,
        by2: null,
        by3: null,
        by4: null,
        by5: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.taskState = [];
      this.queryParams.city = "";
      this.queryParams.town = "";
      this.queryParams.village = "";
      this.queryParams.superviseDeptCode = "";
      this.handleQuery();
    },
    handleAddQuery() {
      this.queryAddParams.pageNum = 1;
      this.getAddList();
    },
    /** 重置按钮操作 */
    resetAddQuery() {
      this.resetForm("queryAddForm");
      this.queryAddParams.city = "";
      this.queryAddParams.town = "";
      this.queryAddParams.village = "";
      this.queryAddParams.taskResultType = "";
      this.taskStates = "";
      this.queryAddParams.superviseDeptCode = "";
      this.handleAddQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.superviseId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    handleAddSelectionChange(selection) {
      this.idsAdds = selection.map((item) => item.dkbm);
      this.idsAdd = selection.map((item) => item.superviseDeptCode);
      this.singleAdd = selection.length !== 1;
      this.multipleAdd = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      // this.openList = true;
      this.open = true;
      this.title = "新增监督任务";
      if (this.iscountry) {
        this.isShow = false;
        this.form.taskType = this.superviseTaskType[0].dictValue;
        getInfo().then((response) => {
          let deptCode = response.user.dept.deptCode;
          this.form.taskDeptCode = deptCode;
          this.deptCode = deptCode;
          childlistUse(deptCode).then((response) => {
            this.zzFormData = response.data;
          });
          if (deptCode.length == 4) {
            //新区
            this.deptCodeStep = 0;
            this.cityFormShow = true;
            this.townFormShow = true;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.cityQueryData = response.data;
            });

            let newdeptCode = deptCode.substring(0, 2);
            childlistUse(newdeptCode).then((response) => {
              this.cityFormData = response.data;
            });
          } else if (deptCode.length == 6) {
            //县
            this.deptCodeStep = 1;
            this.cityFormShow = false;
            this.townFormShow = true;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.townQueryData = response.data;
            });
            let newdeptCode = deptCode.substring(0, 4);
            childlistUse(newdeptCode).then((response) => {
              this.cityFormData = response.data;
            });
          } else if (deptCode.length == 9) {
            //镇
            this.deptCodeStep = 2;
            this.cityFormShow = false;
            this.townFormShow = false;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.villageQueryData = response.data;
            });
            let newdeptCode = deptCode.substring(0, 6);
            childlistUse(newdeptCode).then((response) => {
              this.townFormData = response.data;
            });
          } else if (deptCode.length == 12) {
            //村
            this.cityFormShow = false;
            this.townFormShow = false;
            this.villageFormShow = false;
            this.deptCodeStep = 3;
            let newdeptCode = deptCode.substring(0, 6);
            childlistUse(newdeptCode).then((response) => {
              this.villageFormData = response.data;
            });
          }
        });
      } else {
        getInfo().then((response) => {
          let deptCode = response.user.dept.deptCode;
          /*  this.form.taskDeptCode = deptCode;
            this.deptCode = deptCode;*/
          if (deptCode.length == 4) {
            //新区
            this.deptCodeStep = 0;
            this.cityFormShow = true;
            this.townFormShow = true;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.cityQueryData = response.data;
            });
          } else if (deptCode.length == 6) {
            //县
            this.deptCodeStep = 1;
            this.cityFormShow = false;
            this.townFormShow = true;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.townQueryData = response.data;
            });
          } else if (deptCode.length == 9) {
            //镇
            this.deptCodeStep = 2;
            this.cityFormShow = false;
            this.townFormShow = false;
            this.villageFormShow = true;
            childlistUse(deptCode).then((response) => {
              this.villageQueryData = response.data;
            });
          } else if (deptCode.length == 12) {
            //村
            this.cityFormShow = false;
            this.townFormShow = false;
            this.villageFormShow = false;
            this.deptCodeStep = 3;
          }
        });
      }
    },
    handleSendTask() {
      this.reset();
      this.open = true;
      // this.open = true;
      this.title = "任务派发";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const superviseId = row.superviseId || this.ids;
      getSupervise(superviseId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改监督管理";
      });
    },
    pres() {
      this.active = this.active - 1;
    },
    next() {
      let _this = this;
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (_this.form.taskType == "0") {
            if (
              (_this.form.synergistic == "" ||
                _this.form.synergistic == null) &&
              !_this.iscountry
            ) {
              _this.$message.warning("请选择协同检查");
            } else {
              if (
                ((_this.form.coinspector == "" ||
                  _this.form.coinspector == null) &&
                  _this.form.synergistic == "Y" &&
                  !_this.iscountry) ||
                ((_this.form.coinspectTime == "" ||
                  _this.form.coinspectTime == null) &&
                  _this.form.synergistic == "Y" &&
                  !_this.iscountry)
              ) {
                _this.$message.warning("协同单位或协同时间不能为空");
              } else {
                if (this.form.randomable) {
                  if (
                    _this.form.randomPercent == null ||
                    _this.form.randomPercent == ""
                  ) {
                    _this.$message.warning("请输入比例");
                  } else {
                    this.active = this.active + 1;
                    this.getAddList();
                  }
                } else {
                  this.active = this.active + 1;
                  this.getAddList();
                }
              }
            }
          } else {
            let deptCode = _this.form.taskDeptCode;
            if (deptCode.length == 4) {
              childlistUse(deptCode).then((response) => {
                // this.townAddData = response.data;
                this.cityQueryData = response.data;
              });
            } else if (deptCode.length == 6) {
              _this.cityFormShow = false;
              childlistUse(deptCode).then((response) => {
                // this.townAddData = response.data;
                this.townQueryData = response.data;
              });
            } else if (deptCode.length == 9) {
              _this.townFormShow = false;
              childlistUse(deptCode).then((response) => {
                // this.townAddData = response.data;
                this.villageQueryData = response.data;
              });
            }
            if (this.form.randomable) {
              if (
                _this.form.randomPercent == null ||
                _this.form.randomPercent == ""
              ) {
                _this.$message.warning("请输入比例");
              } else {
                this.active = this.active + 1;
                this.getAddList();
              }
            } else {
              this.active = this.active + 1;
              this.getAddList();
            }
          }
        }
      });
    },
    /** 提交按钮 */
    submitForm(e) {
      let _this = this;
      let dat = new Date(this.form.assignTime);
      var year = dat.getFullYear();
      var mon =
        dat.getMonth() + 1 < 10
          ? "0" + (dat.getMonth() + 1)
          : dat.getMonth() + 1;
      var data = dat.getDate() < 10 ? "0" + dat.getDate() : dat.getDate();
      let datas = year + "-" + mon + "-" + data + " 00:00:00";
      let taskCheckType = this.form.taskCheckType.toString();

      if (_this.form.taskType == "0") {
        if (
          (_this.form.synergistic == "" || _this.form.synergistic == null) &&
          !_this.iscountry
        ) {
          _this.$message.warning("请选择协同检查");
        } else {
          if (
            ((_this.form.coinspector == "" || _this.form.coinspector == null) &&
              _this.form.synergistic == "Y" &&
              !_this.iscountry) ||
            ((_this.form.coinspectTime == "" ||
              _this.form.coinspectTime == null) &&
              _this.form.synergistic == "Y" &&
              !_this.iscountry)
          ) {
            _this.$message.warning("协同单位或协同时间不能为空");
          } else {
            let coinspector = "";
            if (this.form.synergistic == "Y") {
              coinspector = this.form.coinspector.toString();
            } else {
              coinspector = "";
            }
            if (this.form.randomable) {
              let superviseDeptCodes = this.superviseAddList.map(
                (item) => item.superviseDeptCode
              );
              let superviseDeptCodess = this.superviseAddList.map(
                (item) => item.dkbm
              );
              if (superviseDeptCodes.length < 1) {
                this.$message.warning("该任务接收单位无可监管的退耕土地");
              } else {
                var obj = {
                  dkbm: superviseDeptCodess,
                  keys: superviseDeptCodes,
                  body: {
                    taskType: this.form.taskType,
                    synergistic: this.form.synergistic,
                    taskCheckType: taskCheckType,
                    taskDeptCode: this.form.taskDeptCode,
                    coinspector: coinspector,
                    planCompleteTime: this.form.planCompleteTime,
                    coinspectTime: this.form.coinspectTime,
                    randomable: this.form.randomable,
                    randomPercent: this.form.randomPercent,
                    assignTime: datas,
                  },
                };
                if (e == "1") {
                  obj.body["by2"] = "1";
                }
                distributeSupervise(obj).then((response) => {
                  this.msgSuccess("派发成功");
                  this.open = false;
                  this.getList();
                });
              }
            } else {
              let superviseDeptCodes = _this.idsAdd;
              if (superviseDeptCodes.length < 1) {
                this.$message.warning("该任务接收单位无可监管的退耕土地");
              } else {
                var obj = {
                  dkbm: _this.idsAdds,
                  keys: superviseDeptCodes,
                  body: {
                    taskType: this.form.taskType,
                    synergistic: this.form.synergistic,
                    taskCheckType: taskCheckType,
                    taskDeptCode: this.form.taskDeptCode,
                    coinspector: coinspector,
                    planCompleteTime: this.form.planCompleteTime,
                    coinspectTime: this.form.coinspectTime,
                    randomable: this.form.randomable,
                    randomPercent: this.form.randomPercent,
                    assignTime: datas,
                  },
                };
                if (e == "1") {
                  obj.body["by2"] = "1";
                }
                distributeSupervise(obj).then((response) => {
                  this.msgSuccess("派发成功");
                  this.open = false;
                  this.getList();
                });
              }
            }
          }
        }
      } else {
        if (this.form.randomable) {
          let superviseDeptCodes = this.superviseAddList.map(
            (item) => item.superviseDeptCode
          );
          let superviseDeptCodess = this.superviseAddList.map(
            (item) => item.dkbm
          );
          if (superviseDeptCodes.length < 1) {
            this.$message.warning("该任务接收单位无可监管的退耕土地");
          } else {
            var obj = {
                  dkbm: superviseDeptCodess,
                  keys: superviseDeptCodes,
                  body: {
                    taskType: this.form.taskType,
                    synergistic: this.form.synergistic,
                    taskCheckType: taskCheckType,
                    taskDeptCode: this.form.taskDeptCode,
                    coinspector: coinspector,
                    planCompleteTime: this.form.planCompleteTime,
                    coinspectTime: this.form.coinspectTime,
                    randomable: this.form.randomable,
                    randomPercent: this.form.randomPercent,
                    assignTime: datas,
                  },
                
                }
                if(e == '1'){
                  obj.body['by2'] = '1'
                }
            distributeSupervise(obj).then((response) => {
              this.msgSuccess("派发成功");
              this.open = false;
              this.getList();
            });
          }
        } else {
          let superviseDeptCodes = _this.idsAdd;
          if (superviseDeptCodes.length < 1) {
            this.$message.warning("该任务接收单位无可监管的退耕土地");
          } else {
               var obj = {
                  dkbm: _this.idsAdds,
                  keys: superviseDeptCodes,
                  body: {
                    taskType: this.form.taskType,
                    synergistic: this.form.synergistic,
                    taskCheckType: taskCheckType,
                    taskDeptCode: this.form.taskDeptCode,
                    coinspector: coinspector,
                    planCompleteTime: this.form.planCompleteTime,
                    coinspectTime: this.form.coinspectTime,
                    randomable: this.form.randomable,
                    randomPercent: this.form.randomPercent,
                    assignTime: datas,
                  },
                };
                if (e == "1") {
                  obj.body["by2"] = "1";
                }
            distributeSupervise(obj).then((response) => {
              this.msgSuccess("派发成功");
              this.open = false;
              this.getList();
            });
          }
        }
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const superviseIds = row.superviseId || this.ids;
      this.$confirm("是否确认删除监督任务的数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delSupervise(superviseIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有监督管理数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportSupervise(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>
<style>
.vue-treeselect__multi-value-item-container {
  padding-top: 1px;
}

.vue-treeselect--has-value .vue-treeselect__multi-value {
  margin-bottom: -2px;
}

.el-form-item--medium .el-form-item__content {
  line-height: 25px;
}

.myTitle {
  margin: 10px 0;
  color: #1890ff;
  font-size: 16px;
}

.show-icon {
  text-align: center;
  background-color: #5aaafa;
  color: #fff;
  float: right;
  font-size: 12px;
  margin-right: -8px;
  padding: 8px 5px 8px 5px;
  width: 400px;
}

.show-signal {
  border: 4px solid #939393;
  border-right: 4px solid transparent;
  border-bottom: 4px solid transparent;
  float: right;
  margin-right: -400px;
  margin-top: 29px;
  width: 0;
  height: 0;
}

.btn-custom-cancel {
  float: right;
  margin-left: 10px;
}

.statusDv {
  display: flex;
  justify-content: center;
  align-items: center;
}

.statudPoint {
  border-radius: 50px;
  width: 6px;
  height: 6px;
  margin-right: 6px;
}

/*审核通过背景色*/
.Bg2 {
  background-color: #13ce66;
}

/*未提交*/
.Bg0 {
  background-color: #1890ff;
}

/*待审核*/
.Bg1 {
  background-color: orange;
}

/*审核失败*/
.Bg3 {
  background-color: red;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  height: 148px;
  line-height: 148px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.maxtable {
  margin-top: 30px;
}

.per100 {
  background-color: #fda49f !important;
}

.per75-100 {
  background-color: #f1d3ab !important;
}

.per50-75 {
  background-color: #f1e7ab !important;
}

.per25-50 {
  background-color: #c6ffff !important;
}

.per0-25 {
  background-color: #c7f2aa !important;
}

.per-100 {
  background-color: #7cfa86 !important;
}

.ivu-table th {
  background-color: white;
}

.compare {
  color: #ffb806;
  cursor: pointer;
}

.credited {
  float: right;
  margin: 20px 15px 5px 15px;
}

.table {
  clear: both;
}

.colbor {
  display: inline-block;
  width: 30px;
  border: 1px solid #c4c8cc;
}

.ivu-col-span-3 {
  position: absolute;
  bottom: 0px;
  right: 10px;
}
</style>
